import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:whale/helper/utils/util.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class ImListPage extends GetView<ImListController> {
  const ImListPage({Key? key}) : super(key: key);

  // 主视图
  Widget _buildView() {
    var state = controller.state;
    var list = state.list;
    return PlanedListView(
      itemCount: (section) {
        return list?.length ?? 0;
      },
      itemBuilder: (section, item) {
        var md = list![item];
        return ImListCell(
          md: md,
          onTap: () => controller.actionCell(md),
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<ImListController>(
      builder: (_) {
        return Scaffold(
          appBar: detailAppBar(context, title: '消息列表'),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
